package com.sinosoft.flow.web;

import com.sinosoft.flow.domain.props.MinioProp;
import com.sinosoft.flow.service.CommService;
import com.sinosoft.flow.service.TestAuyowiredService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: tangyongbo
 * @Description:
 * @Date: create in 2021/11/18 9:19
 */
@RequestMapping("/api")
@RestController
@Api("通用工具类")
public class CommController {

    @Resource
    MinioProp minioProp;

    /**
     * 1.
     * @Qualifier("Autowired1ServiceImpl")
     * @Autowired   byType
     *
     * 2.使目前采用
     * byName
     */
    @Resource(name = "Autowired1ServiceImpl")
    TestAuyowiredService testAuyowiredService;

    @Resource
    private CommService commService;

    @GetMapping("/minioConfig")
    public MinioProp findMinioProp(){
        return minioProp;
    }

    @PostMapping("/upload")
    public void upload(MultipartFile file) throws Exception {
        commService.upload(file);
    }

    @GetMapping("/download")
    public void download(@RequestParam String fileName, HttpServletResponse response) throws Exception {
        commService.download(fileName,response);

    }

    @GetMapping("/downloadZip")
    public void downloadZip(@RequestParam String fileName, HttpServletResponse response) throws Exception {
        commService.downloadZip(fileName,response);
    }

    @GetMapping("/aotowired")
    public String aotowired(){
        return testAuyowiredService.test1();
    }

}
